//
//  SEGBillHeaderViewCell.m
//  ExcellentHome
//
//  Created by 刘山 on 16/12/12.
//  Copyright © 2016年 陈区. All rights reserved.
//

#import "SEGBillHeaderViewCell.h"

@implementation SEGBillHeaderViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier WithStype:(SEGBillHeaderViewCellType)type
{

    if (self == [self initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI:type];
    }

    return self;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI:(SEGBillHeaderViewCellType)type {
    [self setupUI];
    [self setHeaderCellType:type];
}

- (void)updateUIWithType:(SEGBillHeaderViewCellType)type {
    [self setHeaderCellType:type];
}

- (void)setupUI {
    self.selectionStyle = UITableViewCellSelectionStyleNone;

    //项目
    [self.contentView addSubview:self.ContentLabel];
    [self.ContentLabel setFont:[UIFont systemFontOfSize:13]];
    [self.ContentLabel setTextColor:kColor_1];
    self.ContentLabel.numberOfLines = 0;
    self.ContentLabel.textAlignment = NSTextAlignmentCenter;

    //费用
    [self.contentView addSubview:self.ContentLabel1];
    [self setAttrWithlabel:self.ContentLabel1];

    //缴费情况
    [self.contentView addSubview:self.ContentLabel2];
    [self setAttrWithlabel:self.ContentLabel2];

    //分割线
    [self.contentView addSubview:self.topLineView];
    [self.topLineView setBackgroundColor:kColor_L2];

    //分割线
    [self.contentView addSubview:self.lineView];
    [self.lineView setBackgroundColor:kColor_L2];

    //当月统计
    [self.contentView addSubview:self.ContentLabel3];

    //选择框
    [self.contentView addSubview:self.ContentBtn];
    [self.ContentBtn setImage:[UIImage imageWithContentsOfFile:SEGPicName(@"btn_list_select_nor")] forState:UIControlStateNormal];
    [self.ContentBtn setImage:[UIImage imageWithContentsOfFile:SEGPicName(@"btn_list_select")] forState:UIControlStateSelected];

    //项目
    [self.ContentLabel setHidden:YES];

    //费用
    [self.ContentLabel1 setHidden:YES];

    //缴费情况
    [self.ContentLabel2 setHidden:YES];

    //分割线
    [self.topLineView setHidden:YES];

    //分割线
    [self.lineView setHidden:YES];

    //当月统计
    [self.ContentLabel3 setHidden:YES];

    //选择框
    [self.ContentBtn setHidden:YES];

    [self.ContentBtn addTarget:self action:@selector(selectedClick:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)selectedClick:(UIButton*)sender
{
    [self.cellDelegate cell_selected:sender IndexPath:self.indexPath];
}

- (void)setAttrWithlabel:(UILabel*)lb
{
    [lb setFont:[UIFont systemFontOfSize:13]];
    [lb setTextColor:kColor_1];
}

- (void)setHeaderCellType:(SEGBillHeaderViewCellType)headerCellType
{
    _headerCellType = headerCellType;

    switch (_headerCellType) {
        case SEGBillHeaderViewCellType_BillDetail: {
            [self CellType_BillDetail];
            break;
        }
        case SEGBillHeaderViewCellType_BillLog: {
            [self CellType_BillLog];
            break;
        }
        case SEGBillHeaderViewCellType_BillMonthCanCheck: {
            [self CellType_BillMonthCanCheck];
            break;
        }
        case SEGBillHeaderViewCellType_BillMonthNoCheck: {
            [self CellType_BillMonthNoCheck];
            break;
        }
        case SEGBillHeaderViewCellType_Footer: {
            [self CellType_Footer];
            break;
        }
        case SEGBillHeaderViewCellType_Data_List: {
            [self CellType_Data_List];
            break;
        }
        case SEGBillHeaderViewCellType_PayLog_List: {
            [self CellType_PayLog_List];
            break;
        }
        case SEGBillHeaderViewCellType_Data_Owe: {
            [self CellType_Data_Owe];
            break;
        }
        case SEGBillHeaderViewCellType_PayLog_Footer: {
            [self CellType_PayLog_Footer];
            break;
        }
        case SEGBillHeaderViewCellType_PayLog_DataDeatil: {
            [self CellType_PayLog_DataDeatil];
            break;
        }
        case SEGBillHeaderViewCellType_BillMonthNoCheck_SigleLine: {
            [self CellType_BillMonthNoCheck_SigleLine];
            break;
        }
        case SEGBillHeaderViewCellType_BillMonthCanCheck_SigleLine: {
            [self CellType_BillMonthCanCheck_SigleLine];
            break;
        }
        case SEGBillHeaderViewCellType_Data_Owe_NoCheckWithPenalty: {
            [self CellType_Data_List_NoCheckWithPenalty];
            break;
        }
        case SEGBillHeaderViewCellType_Data_Owe_CanCheckWithPenalty: {
            [self CellType_Data_List_CanCheckWithPenalty];
            break;
        }
        default: {
            [self hiddenAllSubView];
            break;
        }
    }
}

- (void)clearConstraint {
    [self.ContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
    }];
    [self.ContentLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
    }];
    [self.ContentLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
    }];
    [self.ContentLabel3 mas_makeConstraints:^(MASConstraintMaker *make) {
        
    }];
    [self.topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
    }];
    [self.ContentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
    }];
}

- (void)hiddenAllSubView {
    [self.ContentLabel setHidden:YES];
    //费用
    [self.ContentLabel1 setHidden:YES];
    //缴费情况
    [self.ContentLabel2 setHidden:YES];
    //当月统计
    [self.ContentLabel3 setHidden:YES];
    //分割线
    [self.topLineView setHidden:YES];
    //分割线
    [self.lineView setHidden:YES];
    //选择框
    [self.ContentBtn setHidden:YES];
}

#pragma mark - 头部、尾部有关的展示cell

- (void)CellType_BillDetail
{

    //项目
    [self.ContentLabel setHidden:NO];

    //费用
    [self.ContentLabel1 setHidden:NO];

    //缴费情况
    [self.ContentLabel2 setHidden:NO];
    self.ContentLabel2.textColor = kColor_1;

    //分割线
    [self.topLineView setHidden:NO];
    self.topLineView.backgroundColor = kColor_L2;

    //分割线
    [self.lineView setHidden:YES];
    self.lineView.backgroundColor = kColor_L2;

    //当月统计
    [self.ContentLabel3 setHidden:YES];

    //选择框
    [self.ContentBtn setHidden:YES];
    
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.centerX.equalTo(self.contentView).multipliedBy(0.35);
        make.width.mas_equalTo(ceil(LYScreenWidth()/3.0));
        make.top.equalTo(self.contentView).mas_equalTo(5);
        make.bottom.equalTo(self.contentView).mas_offset(-5);
        make.height.mas_greaterThanOrEqualTo(34);
    }];
    
    [self.ContentLabel1 sizeToFit];
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.center.equalTo(self.contentView);
    }];

    [self.ContentLabel2 sizeToFit];
    [self.ContentLabel2 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.centerY.equalTo(self.contentView);
        make.centerX.equalTo(self.contentView).multipliedBy(1.65);
    }];

    [self.topLineView mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.bottom.equalTo(self.contentView);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
    }];

    //    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
    //        make.left.top.right.equalTo(self);
    //        make.bottom.equalTo(self.topLineView.mas_bottom).mas_offset(1);
    //    }];
}

- (void)CellType_PayLog_Footer
{
    //项目
    [self.ContentLabel setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel];

    //费用
    [self.ContentLabel1 setHidden:YES];
    [self setAttrWithlabel:self.ContentLabel1];

    //缴费情况
    [self.ContentLabel2 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel2];

    //分割线
    [self.topLineView setHidden:NO];

    //分割线
    [self.lineView setHidden:YES];

    //当月统计
    [self.ContentLabel3 setHidden:YES];

    //选择框
    [self.ContentBtn setHidden:YES];

    //SAM:iOS10兼容-cell
    [self.ContentLabel sizeToFit];
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.centerX.equalTo(self.contentView).multipliedBy(0.35);
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
            make.bottom.equalTo(self.contentView).mas_offset(-15);
        }
    }];

    [self.ContentLabel2 sizeToFit];
    [self.ContentLabel2 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.centerX.equalTo(self.contentView).multipliedBy(1.65);
    }];

    [self.topLineView mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView.mas_top).mas_offset(0.5);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
    }];

    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0) {
            make.left.top.right.equalTo(self);
            make.bottom.equalTo(self.ContentLabel.mas_bottom).mas_offset(15);
        }else{
            make.edges.equalTo(self);
        }
    }];
}
- (void)CellType_Footer
{
    //项目
    [self.ContentLabel setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel];

    //费用
    [self.ContentLabel1 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel1];

    //缴费情况
    [self.ContentLabel2 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel2];

    //分割线
    [self.topLineView setHidden:NO];

    //分割线
    [self.lineView setHidden:YES];

    //当月统计
    [self.ContentLabel3 setHidden:YES];

    //选择框
    [self.ContentBtn setHidden:YES];

    [self.ContentLabel sizeToFit];
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        //        make.top.equalTo(self.contentView).mas_offset(15);
        make.centerX.equalTo(self.contentView).multipliedBy(0.35);
        make.centerY.equalTo(self.contentView);
    }];

    [self.ContentLabel1 sizeToFit];
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.center.equalTo(self.contentView);
    }];

    [self.ContentLabel2 sizeToFit];
    [self.ContentLabel2 mas_remakeConstraints:^(MASConstraintMaker* make) {
        //        make.top.equalTo(self.contentView).mas_offset(15);
        make.centerX.equalTo(self.contentView).multipliedBy(1.65);
        make.centerY.equalTo(self.contentView);
    }];

    [self.topLineView mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView.mas_top).mas_offset(0.5);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
    }];

    //    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
    //        make.left.top.right.equalTo(self);
    //        make.bottom.equalTo(self.ContentLabel.mas_bottom).mas_offset(15);
    //    }];
}

- (void)CellType_BillMonthCanCheck
{

    //项目
    [self.ContentLabel setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel];

    //欠费
    [self.ContentLabel1 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel1];

    //缴费情况
    [self.ContentLabel2 setHidden:YES];

    //分割线
    [self.topLineView setHidden:NO];
    self.topLineView.backgroundColor = kColor_L2;

    //分割线
    [self.lineView setHidden:NO];
    self.lineView.backgroundColor = kColor_L2;

    //当月统计
    [self.ContentLabel3 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel3];

    //选择框
    [self.ContentBtn setHidden:NO];
    self.ContentBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    
    [self.ContentBtn sizeToFit];
    [self.ContentBtn mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.left.top.equalTo(self.contentView).mas_offset(15);
    }];

    [self.ContentLabel3 sizeToFit];
    [self.ContentLabel3 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.centerY.equalTo(self.ContentBtn);
        make.left.equalTo(self.ContentBtn.mas_right).mas_offset(12);
    }];

    [self.topLineView mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.ContentBtn.mas_bottom).mas_offset(15);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
    }];

    //--------------

    [self.ContentLabel sizeToFit];
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.topLineView.mas_bottom).mas_offset(15);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];

    [self.ContentLabel1 sizeToFit];
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.topLineView.mas_bottom).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];
//SAM:iOS10兼容-cell
    [self.lineView mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.ContentLabel.mas_bottom).mas_offset(15).priorityHigh();
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.height.mas_equalTo(0.5);
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
            make.bottom.equalTo(self.contentView).mas_offset(-1);
        }
    }];

    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0) {
            make.left.top.right.equalTo(self);
            make.bottom.equalTo(self.lineView.mas_bottom).mas_offset(1);
        }else{
            make.edges.equalTo(self);
        }
    }];
}

- (void)CellType_BillMonthNoCheck
{

    //项目
    [self.ContentLabel setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel];

    //欠费
    [self.ContentLabel1 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel1];

    //缴费情况
    [self.ContentLabel2 setHidden:YES];

    //分割线
    [self.topLineView setHidden:NO];
    self.topLineView.backgroundColor = kColor_L2;

    //分割线
    [self.lineView setHidden:NO];
    self.lineView.backgroundColor = kColor_L2;

    //当月统计
    [self.ContentLabel3 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel3];

    //选择框
    [self.ContentBtn setHidden:YES];

    [self.ContentBtn sizeToFit];
    [self.ContentBtn mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.left.top.equalTo(self.contentView).mas_offset(15);
    }];

    [self.ContentLabel3 sizeToFit];
    [self.ContentLabel3 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.left.top.equalTo(self.contentView).mas_offset(15);
    }];

    [self.topLineView mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.ContentLabel3.mas_bottom).mas_offset(15);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
    }];

    //--------------

    [self.ContentLabel sizeToFit];
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.topLineView.mas_bottom).mas_offset(15);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];

    [self.ContentLabel1 sizeToFit];
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.topLineView.mas_bottom).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];

    //SAM:iOS10兼容-cell
    [self.lineView mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.ContentLabel.mas_bottom).mas_offset(15).priorityHigh();
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.height.mas_equalTo(0.5);
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
            make.bottom.equalTo(self.contentView).mas_offset(-1);
        }
    }];

    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0) {
            make.left.top.right.equalTo(self);
            make.bottom.equalTo(self.lineView.mas_bottom).mas_offset(1);
        }else{
            make.edges.equalTo(self);
        }
    }];
}

- (void)CellType_BillMonthCanCheck_SigleLine {
    [self hiddenAllSubView];
    [self clearConstraint];
    
    //项目
    [self.ContentLabel setHidden:NO];
    self.ContentLabel.textAlignment = NSTextAlignmentLeft;
    self.ContentLabel.textColor = kColor_1;
    self.ContentLabel.font = kFont_15;
    
    //欠费
    [self.ContentLabel1 setHidden:NO];
    [self.ContentLabel1 setFont:kFont_15];
    [self.ContentLabel1 setTextColor:kColor_1];
    
    //选择框
    [self.ContentBtn setHidden:NO];
    self.ContentBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    
    [self.ContentBtn sizeToFit];
    [self.ContentBtn mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.left.top.bottom.mas_equalTo(0);
        make.width.mas_equalTo(45);
    }];
    
    [self.ContentLabel sizeToFit];
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.mas_equalTo(15);
        make.left.mas_equalTo(40);
        make.right.bottom.mas_equalTo(-15);
    }];
    
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.mas_equalTo(-15);
    }];

    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0 ) {
            make.left.top.right.equalTo(self);
            make.bottom.equalTo(self.ContentLabel.mas_bottom).mas_offset(15);
            make.bottom.lessThanOrEqualTo(self.ContentLabel1.mas_bottom).mas_offset(15);
        }else{
            make.edges.equalTo(self);
        }
    }];
}

- (void)CellType_BillMonthNoCheck_SigleLine {
    [self hiddenAllSubView];
    [self clearConstraint];
    
    //项目
    [self.ContentLabel setHidden:NO];
    self.ContentLabel.textAlignment = NSTextAlignmentLeft;
    self.ContentLabel.textColor = kColor_1;
    self.ContentLabel.font = kFont_15;
    
    //欠费
    [self.ContentLabel1 setHidden:NO];
    [self.ContentLabel1 setFont:kFont_15];
    [self.ContentLabel1 setTextColor:kColor_1];
    
    [self.ContentLabel sizeToFit];
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.mas_equalTo(15);
        make.left.mas_equalTo(15);
        make.right.bottom.mas_equalTo(-15);
    }];
    
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.mas_equalTo(-15);
    }];
    
    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0 ) {
            make.left.top.right.equalTo(self);
            make.bottom.equalTo(self.ContentLabel.mas_bottom).mas_offset(15);
            make.bottom.lessThanOrEqualTo(self.ContentLabel1.mas_bottom).mas_offset(15);
        }else{
            make.edges.equalTo(self);
        }
    }];
}

- (void)CellType_Data_Owe
{

    //项目
    [self.ContentLabel setHidden:NO];
    [self.ContentLabel setFont:[UIFont systemFontOfSize:13]];
    [self.ContentLabel setTextColor:kColor_2];

    //欠费
    [self.ContentLabel1 setHidden:NO];
    [self.ContentLabel1 setFont:[UIFont systemFontOfSize:13]];
    [self.ContentLabel1 setTextColor:kColor_2];

    //缴费情况
    [self.ContentLabel2 setHidden:YES];

    //分割线
    [self.topLineView setHidden:YES];
    self.topLineView.backgroundColor = kColor_L2;

    //分割线
    [self.lineView setHidden:YES];
    self.lineView.backgroundColor = kColor_L2;

    //当月统计
    [self.ContentLabel3 setHidden:YES];
    [self setAttrWithlabel:self.ContentLabel3];

    //选择框
    [self.ContentBtn setHidden:YES];

    //SAM:iOS10兼容-cell
    self.ContentLabel.textAlignment = NSTextAlignmentLeft;
    [self.ContentLabel sizeToFit];
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).multipliedBy(0.5).mas_offset(15);
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
            make.bottom.equalTo(self.contentView).mas_offset(-15);
        }
    }];

    [self.ContentLabel1 sizeToFit];
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
            make.bottom.lessThanOrEqualTo(self.contentView.mas_bottom).mas_offset(-15);
        }
    }];

    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0) {
            make.left.top.right.equalTo(self);
            make.bottom.equalTo(self.ContentLabel.mas_bottom).mas_offset(15);
            make.bottom.lessThanOrEqualTo(self.ContentLabel1.mas_bottom).mas_offset(15);
        }else{
            make.edges.equalTo(self);
        }
    }];
}

- (void)CellType_BillLog
{
    //项目
    [self.ContentLabel setHidden:NO];

    //费用
    [self.ContentLabel1 setHidden:YES];

    //缴费情况
    [self.ContentLabel2 setHidden:NO];
    self.ContentLabel2.textColor = kColor_1;

    //分割线
    [self.topLineView setHidden:NO];
    self.topLineView.backgroundColor = kColor_L2;

    //分割线
    [self.lineView setHidden:YES];
    self.lineView.backgroundColor = kColor_L2;

    //当月统计
    [self.ContentLabel3 setHidden:YES];

    //选择框
    [self.ContentBtn setHidden:YES];

    [self.ContentLabel sizeToFit];
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.centerY.equalTo(self.contentView);
        make.centerX.equalTo(self.contentView).multipliedBy(0.35);
    }];

    [self.ContentLabel2 sizeToFit];
    [self.ContentLabel2 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.centerY.equalTo(self.contentView);
        make.centerX.equalTo(self.contentView).multipliedBy(1.65);
    }];

    //SAM:iOS10兼容-cell
    [self.topLineView mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.ContentLabel2.mas_bottom).mas_offset(15);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
            make.bottom.equalTo(self.contentView).mas_offset(-1);
        }
    }];

    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0) {
            make.left.top.right.equalTo(self);
            make.bottom.equalTo(self.topLineView.mas_bottom).mas_offset(1);
        }else{
            make.edges.equalTo(self);
        }
        
    }];
}

- (void)CellType_PayLog_DataDeatil
{
    //项目
    [self.ContentLabel setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel];

    //费用
    [self.ContentLabel1 setHidden:YES];
    [self setAttrWithlabel:self.ContentLabel1];

    //缴费情况
    [self.ContentLabel2 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel2];

    //分割线
    [self.topLineView setHidden:YES];

    //分割线
    [self.lineView setHidden:YES];

    //当月统计
    [self.ContentLabel3 setHidden:YES];

    //选择框
    [self.ContentBtn setHidden:YES];

    //SAM:iOS10兼容-cell
    [self.ContentLabel sizeToFit];
    self.ContentLabel.textAlignment = NSTextAlignmentLeft;
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView.mas_top).mas_offset(20);
        make.centerX.equalTo(self.contentView).multipliedBy(0.35);
//        make.left.equalTo(self.contentView).mas_offset(15);
//        make.right.equalTo(self.contentView).multipliedBy(0.5).mas_offset(15);
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
            make.bottom.equalTo(self.contentView).mas_offset(-20);
        }
    }];

    [self.ContentLabel2 sizeToFit];
    [self.ContentLabel2 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView.mas_top).mas_offset(20);
        make.centerX.equalTo(self.contentView).multipliedBy(1.65);
    }];

    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0) {
            make.left.right.top.equalTo(self);
            make.bottom.equalTo(self.ContentLabel.mas_bottom).mas_offset(20);
        }else{
            make.edges.equalTo(self);
        }
    }];
}
// 缴费详情专用的布局样式
- (void)useBillDetailCellUI {
    [self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_offset(0);
    }];
    
    self.ContentLabel.textAlignment = NSTextAlignmentLeft;
    self.ContentLabel.numberOfLines = 0;
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.mas_offset(15);
        make.bottom.mas_offset(-15);
        make.left.mas_offset(15);
        make.right.equalTo(self.ContentLabel2.mas_left).offset(-8);
    }];
    
    self.ContentLabel2.textAlignment = NSTextAlignmentCenter;
    self.ContentLabel2.numberOfLines = 0;
    [self.ContentLabel2 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.mas_offset(15);
        make.bottom.mas_offset(-15);
        make.right.mas_equalTo(-15);
        make.width.mas_equalTo(75);
    }];
}

#pragma mark - 数据有关的展示cell
- (void)CellType_Data_List
{
    //项目
    [self.ContentLabel setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel];

    //费用
    [self.ContentLabel1 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel1];

    //缴费情况
    [self.ContentLabel2 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel2];

    //分割线
    [self.topLineView setHidden:YES];

    //分割线
    [self.lineView setHidden:YES];

    //当月统计
    [self.ContentLabel3 setHidden:YES];

    //选择框
    [self.ContentBtn setHidden:YES];

    //SAM:iOS10兼容-cell
    [self.ContentLabel sizeToFit];
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView.mas_top).mas_offset(20);
        //make.centerX.equalTo(self.contentView).multipliedBy(0.35);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).multipliedBy(0.37).mas_offset(15);
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
            make.bottom.equalTo(self.contentView).mas_offset(-20);
        }
    }];

    [self.ContentLabel1 sizeToFit];
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView.mas_top).mas_offset(20);
        make.centerX.equalTo(self.contentView);
    }];

    [self.ContentLabel2 sizeToFit];
    [self.ContentLabel2 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView.mas_top).mas_offset(20);
        make.centerX.equalTo(self.contentView).multipliedBy(1.65);
    }];

    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0) {
            make.left.right.top.equalTo(self);
            make.bottom.equalTo(self.ContentLabel.mas_bottom).mas_offset(20);
        }else{
            make.edges.equalTo(self);
        }
        
    }];
}

/// 给缴费情况设置颜色字体大小
- (void)setLabelStatusWithFeeStatus:(SEGBillDetailDoLogicModelFeeStatus)status WithContent:(NSString*)content ForLabel:(UILabel*)lb
{
    [lb setFont:[UIFont systemFontOfSize:13]];
    switch (status) {
    case SEGBillDetailDoLogicModelFeeStatus_PayAll: {
        [lb setText:@"已缴完"];
        [lb setTextColor:kColor_T];
    } break;
    case SEGBillDetailDoLogicModelFeeType_PayPart: {
        [lb setText:[NSString stringWithFormat:@"已缴%@", content]];
        [lb setTextColor:kColor_1];
    } break;
    case SEGBillDetailDoLogicModelFeeType_NoPay: {
        [lb setTextColor:kColor_S1];
        [lb setText:@"未缴"];
    } break;
    default:
        [lb setTextColor:kColor_1];
        [lb setText:content];
        break;
    }
}

///  缴费记录
- (void)CellType_PayLog_List
{

    //时间
    [self.ContentLabel setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel];

    //费用
    [self.ContentLabel1 setHidden:NO];
    [self setAttrWithlabel:self.ContentLabel1];

    //地址
    [self.ContentLabel2 setHidden:NO];
    [self.ContentLabel2 setFont:[UIFont systemFontOfSize:13]];
    [self.ContentLabel2 setTextColor:kColor_2];

    //分割线
    [self.topLineView setHidden:YES];

    //分割线
    [self.lineView setHidden:YES];

    //当月统计
    [self.ContentLabel3 setHidden:YES];

    //选择框
    [self.ContentBtn setHidden:YES];

    self.ContentLabel.textAlignment = NSTextAlignmentLeft;

    [self.ContentLabel sizeToFit];
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.ContentLabel1.mas_left).mas_offset(-15);
    }];

    [self.ContentLabel1 sizeToFit];
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.top.equalTo(self.contentView).mas_offset(15);
    }];

    //SAM:iOS10兼容-cell
    [self.ContentLabel2 sizeToFit];
    [self.ContentLabel2 mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.ContentLabel.mas_bottom).mas_offset(15).priorityHigh();
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
            make.bottom.equalTo(self.contentView).mas_offset(-15);
        }
    }];

    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        // iOS10 以上的适配
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0) {
            make.left.right.top.equalTo(self);
            make.bottom.equalTo(self.ContentLabel2.mas_bottom).mas_offset(15);
        }else{
            make.edges.equalTo(self);
        }
        
    }];
}

- (NSAttributedString*)stringWithAllContents:(NSString*)contents partContent:(NSString*)part
{

    NSMutableAttributedString* attributedString = [[NSMutableAttributedString alloc] initWithString:contents];

    [attributedString addAttributes:@{
        NSFontAttributeName : [UIFont systemFontOfSize:13.f],
        NSForegroundColorAttributeName : kColor_1
    }
                              range:NSMakeRange(0, contents.length)];

    [attributedString addAttributes:@{
        NSFontAttributeName : [UIFont systemFontOfSize:10.f],
        NSForegroundColorAttributeName : kColor_3
    }
                              range:[contents rangeOfString:part]];

    return attributedString;
}

- (void)CellType_Data_List_CanCheckWithPenalty {
    [self clearConstraint];
    [self hiddenAllSubView];
    
    //项目
    [self.ContentLabel setHidden:NO];
    [self.ContentLabel setFont:kFont_13];
    [self.ContentLabel setTextColor:kColor_1];
    self.ContentLabel.textAlignment = NSTextAlignmentLeft;
    [self.ContentLabel sizeToFit];
    
    //欠费
    [self.ContentLabel1 setHidden:NO];
    [self.ContentLabel1 setFont:kFont_13];
    [self.ContentLabel1 setTextColor:kColor_1];
    self.ContentLabel1.textAlignment = NSTextAlignmentRight;
    self.ContentLabel1.numberOfLines = 0;
    [self.ContentLabel1 sizeToFit];
    
    //分割线
    [self.topLineView setHidden:NO];
    self.topLineView.backgroundColor = kColor_L2;
    
    //选择框
    [self.ContentBtn setHidden:NO];
    self.ContentBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    
    
    [self.ContentBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.mas_equalTo(0);
        make.width.mas_equalTo(55);
    }];
    
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(63);
        make.top.mas_equalTo(15);
        make.bottom.mas_equalTo(-15);
        make.width.mas_equalTo((LYScreenWidth()-63-15)*0.65);
        make.height.mas_greaterThanOrEqualTo(20);
    }];
    
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.ContentLabel.mas_right).offset(8);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(15);
        make.bottom.mas_equalTo(-15);
    }];
    
    [self.topLineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(0.5);
    }];
    
    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.edges.equalTo(self);
    }];
}

- (void)CellType_Data_List_NoCheckWithPenalty {
    [self clearConstraint];
    [self hiddenAllSubView];
    
    //项目
    [self.ContentLabel setHidden:NO];
    [self.ContentLabel setFont:kFont_13];
    [self.ContentLabel setTextColor:kColor_1];
    self.ContentLabel.textAlignment = NSTextAlignmentLeft;
    [self.ContentLabel sizeToFit];
    
    //欠费
    [self.ContentLabel1 setHidden:NO];
    [self.ContentLabel1 setFont:kFont_13];
    [self.ContentLabel1 setTextColor:kColor_1];
    self.ContentLabel1.textAlignment = NSTextAlignmentRight;
    self.ContentLabel1.numberOfLines = 0;
    [self.ContentLabel1 sizeToFit];
    
    //分割线
    [self.topLineView setHidden:NO];
    self.topLineView.backgroundColor = kColor_L2;
    
    [self.ContentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(15);
        make.bottom.mas_equalTo(-15);
        make.width.mas_equalTo((LYScreenWidth()-15-15)*0.65);
        make.height.mas_greaterThanOrEqualTo(20);
    }];
    
    [self.ContentLabel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.ContentLabel.mas_right).offset(8);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(15);
        make.bottom.mas_equalTo(-15);
    }];
    
    [self.topLineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(0.5);
    }];
    
    [self.contentView mas_remakeConstraints:^(MASConstraintMaker* make) {
        make.edges.equalTo(self);
    }];
}

- (void)cellUseFillLine {
    //分割线
    [self.topLineView setHidden:NO];
    self.topLineView.backgroundColor = kColor_L2;
    [self.topLineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
    }];
}

#pragma mark - lazy load

- (UIView *)topLineView {
    if (!_topLineView) {
        _topLineView = [[UIView alloc] init];
    }
    return _topLineView;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
    }
    return _lineView;
}

- (UIButton *)ContentBtn {
    if (!_ContentBtn) {
        _ContentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    }
    return _ContentBtn;
}

- (UILabel *)ContentLabel {
    if (!_ContentLabel) {
        _ContentLabel = [[UILabel alloc] init];
    }
    return _ContentLabel;
}

- (UILabel *)ContentLabel1 {
    if (!_ContentLabel1) {
        _ContentLabel1 = [[UILabel alloc] init];
    }
    return _ContentLabel1;
}

- (UILabel *)ContentLabel2 {
    if (!_ContentLabel2) {
        _ContentLabel2 = [[UILabel alloc] init];
    }
    return _ContentLabel2;
}

- (UILabel *)ContentLabel3 {
    if (!_ContentLabel3) {
        _ContentLabel3 = [[UILabel alloc] init];
    }
    return _ContentLabel3;
}

@end
